package top.datacluster.basic.algorithm.leetcode.bit;

public class LeetCodeView56 {

    public int[] singleNumbers(int[] nums) {
        int temp = 0;
        for (int i = 0; i < nums.length; i++){
            temp ^= nums[i];
        }
        int bit = 1;
        while ((bit ^ temp) == 0)
            bit <<= 1;
        int[] result = new int[2];
        for (int i = 0; i < nums.length; i++){
            if ((nums[i] ^ bit) == 0){
                result[0] ^= nums[i];
            }else{
                result[1] ^= nums[i];
            }
        }
        return result;
    }
}
